﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XNA_2DFramwork;

namespace ArtificialIntelligence.MovementComponent.AStar
{
    public class Node<T>
    {
        public List<Node<T>> Neighbors { get; set; }
        public MovementCommad command = new MovementCommad();
		public Func<Node<T>, int> GetHeuristic { get; set; }
		public Func<Node<T>, int> GetCost { get; set; }
		public Func<Node<T>, Node<T>, bool> IsEqualFunc { get; set; }
		public NodeState NodeState { get; set; }
		public T Value { get; set; }
		public T GoalValue { get; set; }
		public Node<T> PreviousNode { get; set; }

		public Node()
		{
			NodeState = NodeState.Undetermined;
			Neighbors = new List<Node<T>>();
		}

		public int GetTotalCost()
		{
			int totalCost = GetHeuristic(this) + GetCost(this);

			return totalCost;
		}

		public bool IsGoalValue()
		{
			return (Value as IComparable).CompareTo(GoalValue as IComparable) == 0;
		}

		public bool IsEqual(Node<T> otherNode)
		{
			return IsEqualFunc(this, otherNode);
		}
	}
  }
